import {request} from "./utils/request";

App({
    onLaunch() {
        const _this = this;
        wx.getSystemInfo({
            success: (result) => {
                _this.globalData.statusBarHeight = result.statusBarHeight + 10;
            },
        })
        console.log(444444444)

        _this.loginPromise = new Promise((resolve, reject) => {
            wx.login({
                success: (loginRes) => {
                    console.log(111111111)
                    request({
                        url: '/api/login/index',
                        method: 'POST',
                        data: {code: loginRes.code}
                    }).then(res => {
                        let result = res.data;
                        _this.globalData.accessToken = result.data.token
                        resolve(result.data.token)
                    }).catch(reject)
                },
                fail: reject
            });
        });
    },
    globalData: {
        statusBarHeight: 0,
        accessToken: '',
        loginPromise: null
    }
})
